#ifndef _UPO_SOLVER_H_
#define _UPO_SOLVER_H_

#include <stack>
#include <vector>
#include "parser.h"

class UPO_solver
{
public:
	UPO_solver(InputData* _inputMatrix);
	~UPO_solver();

	void Solve();
	void WriteSolutionMask();
	int GetActiveNodesNumber(bool* mask, int iNodes);

private:
	struct SystemState
	{
		int indexToNodes;
		int coveredLines;
		int totalNodes;
		int targetNode;

		void InitState()
		{
			indexToNodes = 0;
			coveredLines = 0;
			totalNodes = 0;
		}

		void CopyState(SystemState state)
		{
			totalNodes = state.totalNodes;
			coveredLines = state.coveredLines;
			indexToNodes = state.indexToNodes;
			targetNode = state.targetNode;
		}

	};

	struct Solution
	{
		int activeNodes;
		bool* solutionMask;

		void CopyMask(bool* mask, int totalNodes)
		{
			for(int i = 0; i < totalNodes; i++)
			{
				solutionMask[i] = mask[i];
			}
		}
	};

	InputData* inputMatrix;
	int LinesNumber;
	std::stack<SystemState> MainStack;
	Solution currentBestSolution;

	bool* CurrentNodesMask;
	
};


#endif
